package com.mz.mattress.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mz.mattress.api.entity.Sale;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SaleMapper extends BaseMapper<Sale> {

    Page<Sale> listPage(Page page,
                        @Param("province") String province,
                        @Param("city") String city,
                        @Param("district") String district,
                        @Param("name") String name,
                        @Param("status") Integer status,
                        @Param("pid") Integer pid,
                        @Param("startTime") String startTime,
                        @Param("endTime") String endTime);

    @Select("select * from mz_sale where mobile=#{mobile} and deleted=0 limit 1")
    Sale selectByMobile(@Param("mobile") String mobile);

    @Select("select id,mobile,name from mz_sale where mobile like concat('%', #{mobile}, '%') and status=0 and deleted=0 limit 5")
    List<Sale> searchByMobile(@Param("mobile") String mobile);

    @Select("select * from mz_sale where pid=#{pid} and deleted=0")
    List<Sale> selectByPid(@Param("pid") Integer pid);

    @Delete("delete from mz_sale where mobile=#{mobile}")
    void deleteByMobile(@Param("mobile") String mobile);

    //商家提交审核 执行
//    @Update("update mz_sale set merchant_apply=merchant_apply+1 where id=#{id}")
//    void updateMerchantSubmit(@Param("id") Integer id);

//    //商家审核通过 执行
//    @Update("update mz_sale set merchant_sum=merchant_sum+1,merchant_apply=merchant_apply-1 where id=#{id}")
//    void updateMerchantCheckPass(@Param("id") Integer id);
//
//    //商家审核失败 执行
//    @Update("update mz_sale set merchant_apply=merchant_apply-1 where id=#{id}")
//    void updateMerchantCheckFail(@Param("id") Integer id);

//    //设备绑定商家 执行
//    @Update("update mz_sale set device_sum=device_sum+1 where id=#{id}")
//    void updateDeviceBind(@Param("id") Integer id);
//
//    //设备解绑商家 执行
//    @Update("update mz_sale set device_sum=device_sum-1 where id=#{id}")
//    void updateDeviceUnbind(@Param("id") Integer id);

    @Select("select * from mz_sale where deleted=0")
    List<Sale> list();

}
